package com.xbts.system.domain;

import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotEmpty;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.util.Objects;
import javax.validation.constraints.NotNull;
import com.xbts.common.annotation.Excel;
import com.xbts.common.utils.StringUtils;
import com.xbts.common.core.domain.BaseEntity;
import lombok.NoArgsConstructor;

/**
 * 用户工单对象 cn_user_cases
 *
 * @author xbts
 * @date 2023-08-10
 */
@Data
@ApiModel("用户工单对象")
@TableName("cn_user_cases")
@NoArgsConstructor
@AllArgsConstructor
public class CnUserCases extends BaseEntity {

private static final long serialVersionUID=1L;

    /** 工单主键 */
    @TableId
    private Long casesId;
    /** 用户id */
    @Excel(name = "用户id")
    @ApiModelProperty("用户id")
    @NotEmpty(message = "用户id不能为空")
    private Long userId;
    /** 工单id */
    @Excel(name = "工单id")
    @ApiModelProperty("工单id")
    @NotEmpty(message = "工单id不能为空")
    private String incidentId;
    /** 工单描述 */
    @Excel(name = "工单描述")
    @ApiModelProperty("工单描述")
    @NotEmpty(message = "工单描述不能为空")
    private String simpleDescription;
    /** 问题类型id */
    @Excel(name = "问题类型id")
    @ApiModelProperty("问题类型id")
    @NotNull(message = "问题类型id不能为空")
    private String businessTypeId;
    /** 问题类型名称 */
    @Excel(name = "问题类型名称")
    @ApiModelProperty("问题类型名称")
    @NotEmpty(message = "问题类型名称不能为空")
    private String businessTypeName;
    /** 对应的工单类型0咨询 5报障 */
    @Excel(name = "对应的工单类型0咨询 5报障")
    @ApiModelProperty("对应的工单类型0咨询 5报障")
    @NotEmpty(message = "对应的工单类型0咨询 5报障不能为空")
    private String caseType;

    /** 工单状态 0：待受理 1：处理中 2：待确认结果 3：已完成 4：已撤销 12：无效 17： 待反馈 */
    @TableField(exist = false)
    private String status;

    public<T> QueryWrapper<T> queryWrapper(){
        QueryWrapper<T> queryWrapper=new QueryWrapper<>();
        queryWrapper.like(StringUtils.isNotEmpty(incidentId),"incident_id",incidentId);
        queryWrapper.like(StringUtils.isNotEmpty(simpleDescription),"simple_description",simpleDescription);
        queryWrapper.eq(!Objects.isNull(businessTypeId),"business_type_id",businessTypeId);
        queryWrapper.like(StringUtils.isNotEmpty(businessTypeName),"business_type_name",businessTypeName);
        queryWrapper.like(StringUtils.isNotEmpty(caseType),"case_type",caseType);
        return queryWrapper;
    }
}